﻿using System.Reflection.Metadata;
using Bean.Quartz.Core;
using Microsoft.Extensions.Logging;
using static CSRedis.CSRedisClient;

namespace Bean.PolicyBackend.Handler
{
    /// <summary>
    /// 订阅
    /// </summary>
    public class TestSubscribe
    {
        private readonly ILogger<TestSubscribe> _logger;
        private SubscribeObject client = null!;
        
        private readonly QuartzStartup _quartzStartup;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="logger"></param>
        public TestSubscribe(ILogger<TestSubscribe> logger)
        {
            _logger = logger;
        }

        /// <summary>
        /// 消息订阅
        /// </summary>
        public void Start()
        {
            // client = RedisHelper.Subscribe((Constant.Key_WeChat_Subscribe_SyncRobot, async void (msg) => await Sub(msg)));
            //
            // async Task Sub(SubscribeMessageEventArgs msg)
            // {
            //     _logger.LogInformation($"{msg.Body}");
            //
            //     var data = msg.Body.ToObj<WeChatSyncRobotEventDto>();
            //     await EventHandler(data);
            // }
        }

        /// <summary>
        /// 消息停止
        /// </summary>
        public void Stop()
        {
            client.Unsubscribe();
        }
    }
}